import java.util.Random;

public class Generator {
	Random gen;
	boolean[] cards;
	
	public Generator(){
		gen = new Random();
		cards = new boolean[52];
		this.resetcards();
	}
	
	public void resetcards(){
		for(int i=0;i<52;i++)
			cards[i] = false;
	}
	
	public Holding make_holding(){
		Card c1 = this.make_card();

		Card c2 = this.make_card();

		Holding h = new Holding(c1,c2);

		return h;
	}
	
	public Card[] make_board(){
		Card[] board = new Card[5];
		for(int i=0;i<5;i++)
			board[i] = this.make_card();
		
		return board;
	}
	

	
	public Card make_card(){
		int v = gen.nextInt(13);
		int c = gen.nextInt(4);
		Card ca = new Card(v,c);
		while(cards[ca.cardid()]){
			v = gen.nextInt(13);
			c = gen.nextInt(4);
			ca = new Card(v,c);
		}
		this.cards[ca.cardid()] = true;
		return ca;
	}
	
	public void holdingtaken(Holding h){
		for(int i=0; i<2; i++)
			this.cards[h.getHolding()[i].cardid()] = true;
		
	}
}
